Kameleon-Plus  0.3.2
TimeInterpolator.h
Go to the documentation of this file.
1 /*
2  * TimeInterpolator.h
3  *
4  * Created on: Aug 24, 2012
5  * Author: dberrios
6  */
7 
8 #ifndef TIMEINTERPOLATOR_H_
9 #define TIMEINTERPOLATOR_H_
10 
11 #include <boost/unordered_map.hpp>
12 #include <vector>
13 #include "Kameleon.h"
14 #include "Interpolator.h"
15 #include "CCMCTime.h"
16 
17 namespace ccmc
18 {
19 
20 
21  class Kameleon;
22 
23  /*
24  *
25  */
27  {
28  public:
30  virtual ~TimeInterpolator();
31  void addTimestep(const std::string& filename);
32  void removeTimestep(const Time& time);
33  std::vector<Time> getTimesteps();
34  Interpolator * getInterpolator(const Time& time);
35  Kameleon * getKameleon(const Time& time);
36  bool manageMemory(const Time& time, const std::vector<std::string>& variable);
37  bool manageMemory(const Time& time, const char * variable[], int numVars);
38  void closeAndCleanupMemory();
39  // bool unloadVariable(const Time& time, const std::string& variable); //Not implemented yet
40  float interpolate(const Time& time, const std::string& variable, const float& c0, const float& c1, const float& c2);
41  float interpolate(const Time& time, int variable, const float& c0, const float& c1, const float& c2);
42  void clearAll();
43  static Time parseTime(const std::string& timeString);
44  static std::string toString(const Time& time);
45 
46  private:
47  std::vector<Time> timesteps;
48  boost::unordered_map<Time, const std::string> timesteps_map;
49  boost::unordered_map<Time, Kameleon *> current_kameleon_files;
50  boost::unordered_map<Time, Interpolator *> current_kameleon_interpolators;
51  bool isSorted;
52 
53  void manageVariables(const std::vector<std::string>& variables, Kameleon* a);
54  void manageVariables(const char * variables[], int numVars, Kameleon* a);
55  };
56 }
57 
58 #endif /* TIMEINTERPOLATOR_H_ */